<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>相册选择</title>
</head>

<body>
    <p><textarea name="" id="area" cols="30" rows="10"></textarea></p>
    <p><input type="submit" value="发布" id="input"></p>
    <p id="res"></p>
    <script>
        let area = document.getElementById("area");
        const input = document.getElementById("input")
        const res = document.getElementById("res")
        // /左边开始，右边结束/，g表示查找所有匹配项，i表示忽略大小写
        let reg = /金|木/g

        input.onclick = () => {
            let newVue = area.value.replace(reg, '*')
            console.log(newVue);

            res.innerText = newVue
        }
    </script>
</body>

</html>